<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.9.1"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>MQTT C Client Libraries Internals: Heap.c File Reference</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectlogo"><img alt="Logo" src="pahologo.png"/></td>
  <td id="projectalign" style="padding-left: 0.5em;">
   <div id="projectname">MQTT C Client Libraries Internals
   </div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.9.1 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
var searchBox = new SearchBox("searchBox", "search",false,'Search','.html');
/* @license-end */
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
$(function() {
  initMenu('',true,false,'search.php','Search');
  $(document).ready(function() { init_search(); });
});
/* @license-end */</script>
<div id="main-nav"></div>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

</div><!-- top -->
<div class="header">
  <div class="summary">
<a href="#nested-classes">Data Structures</a> &#124;
<a href="#define-members">Macros</a> &#124;
<a href="#typedef-members">Typedefs</a> &#124;
<a href="#func-members">Functions</a> &#124;
<a href="#var-members">Variables</a>  </div>
  <div class="headertitle">
<div class="title">Heap.c File Reference</div>  </div>
</div><!--header-->
<div class="contents">

<p>functions to manage the heap with the goal of eliminating memory leaks  
<a href="#details">More...</a></p>
<div class="textblock"><code>#include &quot;Tree.h&quot;</code><br />
<code>#include &quot;Log.h&quot;</code><br />
<code>#include &quot;StackTrace.h&quot;</code><br />
<code>#include &quot;Thread.h&quot;</code><br />
<code>#include &lt;stdlib.h&gt;</code><br />
<code>#include &lt;string.h&gt;</code><br />
<code>#include &lt;stdio.h&gt;</code><br />
<code>#include &lt;stddef.h&gt;</code><br />
<code>#include &lt;inttypes.h&gt;</code><br />
<code>#include &quot;Heap.h&quot;</code><br />
</div><div class="textblock"><div class="dynheader">
Include dependency graph for Heap.c:</div>
<div class="dyncontent">
<div class="center"><img src="Heap_8c__incl.png" border="0" usemap="#aHeap_8c" alt=""/></div>
<map name="aHeap_8c" id="aHeap_8c">
<area shape="rect" title="functions to manage the heap with the goal of eliminating memory leaks" alt="" coords="180,5,243,32"/>
<area shape="rect" title=" " alt="" coords="5,80,68,107"/>
<area shape="rect" title=" " alt="" coords="93,80,157,107"/>
<area shape="rect" title=" " alt="" coords="181,80,241,107"/>
<area shape="rect" title=" " alt="" coords="265,80,333,107"/>
<area shape="rect" title=" " alt="" coords="358,80,435,107"/>
</map>
</div>
</div><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="nested-classes"></a>
Data Structures</h2></td></tr>
<tr class="memitem:"><td class="memItemLeft" align="right" valign="top">struct &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="structstorageElement.html">storageElement</a></td></tr>
<tr class="memdesc:"><td class="mdescLeft">&#160;</td><td class="mdescRight">Each item on the heap is recorded with this structure.  <a href="structstorageElement.html#details">More...</a><br /></td></tr>
<tr class="separator:"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="define-members"></a>
Macros</h2></td></tr>
<tr class="memitem:a8ee400b3ef078dd6b8075360a3b656a8"><td class="memItemLeft" align="right" valign="top"><a id="a8ee400b3ef078dd6b8075360a3b656a8"></a>
#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="Heap_8c.html#a8ee400b3ef078dd6b8075360a3b656a8">PRIeyecatcher</a>&#160;&#160;&#160;PRIx64</td></tr>
<tr class="memdesc:a8ee400b3ef078dd6b8075360a3b656a8"><td class="mdescLeft">&#160;</td><td class="mdescRight">print eyecatcher in HEX notation <br /></td></tr>
<tr class="separator:a8ee400b3ef078dd6b8075360a3b656a8"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="typedef-members"></a>
Typedefs</h2></td></tr>
<tr class="memitem:a4b30ee6c344ce54b9430de1515d24872"><td class="memItemLeft" align="right" valign="top"><a id="a4b30ee6c344ce54b9430de1515d24872"></a>
typedef uint64_t&#160;</td><td class="memItemRight" valign="bottom"><b>eyecatcherType</b></td></tr>
<tr class="separator:a4b30ee6c344ce54b9430de1515d24872"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="func-members"></a>
Functions</h2></td></tr>
<tr class="memitem:ae75b06db0cdfce5c281f8672e8577854"><td class="memItemLeft" align="right" valign="top">static size_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="Heap_8c.html#ae75b06db0cdfce5c281f8672e8577854">Heap_roundup</a> (size_t size)</td></tr>
<tr class="memdesc:ae75b06db0cdfce5c281f8672e8577854"><td class="mdescLeft">&#160;</td><td class="mdescRight">Round allocation size up to a multiple of the size of an int.  <a href="Heap_8c.html#ae75b06db0cdfce5c281f8672e8577854">More...</a><br /></td></tr>
<tr class="separator:ae75b06db0cdfce5c281f8672e8577854"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a45db32d4f454f94d7f4574deced5ee33"><td class="memItemLeft" align="right" valign="top">static int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="Heap_8c.html#a45db32d4f454f94d7f4574deced5ee33">ptrCompare</a> (void *a, void *b, int value)</td></tr>
<tr class="memdesc:a45db32d4f454f94d7f4574deced5ee33"><td class="mdescLeft">&#160;</td><td class="mdescRight"><a class="el" href="structList.html" title="Structure to hold all data for one list.">List</a> callback function for comparing storage elements.  <a href="Heap_8c.html#a45db32d4f454f94d7f4574deced5ee33">More...</a><br /></td></tr>
<tr class="separator:a45db32d4f454f94d7f4574deced5ee33"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:afa283972f1bf265ebe538e80198fb674"><td class="memItemLeft" align="right" valign="top"><a id="afa283972f1bf265ebe538e80198fb674"></a>
static void&#160;</td><td class="memItemRight" valign="bottom"><b>checkEyecatchers</b> (char *file, int line, void *p, size_t size)</td></tr>
<tr class="separator:afa283972f1bf265ebe538e80198fb674"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ac23c370399a3c7b9aa9fa9d0672be122"><td class="memItemLeft" align="right" valign="top">static int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="Heap_8c.html#ac23c370399a3c7b9aa9fa9d0672be122">Internal_heap_unlink</a> (char *file, int line, void *p)</td></tr>
<tr class="memdesc:ac23c370399a3c7b9aa9fa9d0672be122"><td class="mdescLeft">&#160;</td><td class="mdescRight">Remove an item from the recorded heap without actually freeing it.  <a href="Heap_8c.html#ac23c370399a3c7b9aa9fa9d0672be122">More...</a><br /></td></tr>
<tr class="separator:ac23c370399a3c7b9aa9fa9d0672be122"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:aafff91620a02cc5f8160ee55dc1d7bf4"><td class="memItemLeft" align="right" valign="top">static void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="Heap_8c.html#aafff91620a02cc5f8160ee55dc1d7bf4">HeapScan</a> (enum LOG_LEVELS log_level)</td></tr>
<tr class="memdesc:aafff91620a02cc5f8160ee55dc1d7bf4"><td class="mdescLeft">&#160;</td><td class="mdescRight">Scans the heap and reports any items currently allocated.  <a href="Heap_8c.html#aafff91620a02cc5f8160ee55dc1d7bf4">More...</a><br /></td></tr>
<tr class="separator:aafff91620a02cc5f8160ee55dc1d7bf4"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a59e53a989d69c3da767487596d9bfa1f"><td class="memItemLeft" align="right" valign="top">void *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="Heap_8c.html#a59e53a989d69c3da767487596d9bfa1f">mymalloc</a> (char *file, int line, size_t size)</td></tr>
<tr class="memdesc:a59e53a989d69c3da767487596d9bfa1f"><td class="mdescLeft">&#160;</td><td class="mdescRight">Allocates a block of memory.  <a href="Heap_8c.html#a59e53a989d69c3da767487596d9bfa1f">More...</a><br /></td></tr>
<tr class="separator:a59e53a989d69c3da767487596d9bfa1f"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a25214c297c998eba3cfc8282b1162c69"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="Heap_8c.html#a25214c297c998eba3cfc8282b1162c69">myfree</a> (char *file, int line, void *p)</td></tr>
<tr class="memdesc:a25214c297c998eba3cfc8282b1162c69"><td class="mdescLeft">&#160;</td><td class="mdescRight">Frees a block of memory.  <a href="Heap_8c.html#a25214c297c998eba3cfc8282b1162c69">More...</a><br /></td></tr>
<tr class="separator:a25214c297c998eba3cfc8282b1162c69"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a5f453bffe39551109e282c904a6f2902"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="Heap_8c.html#a5f453bffe39551109e282c904a6f2902">Heap_unlink</a> (char *file, int line, void *p)</td></tr>
<tr class="memdesc:a5f453bffe39551109e282c904a6f2902"><td class="mdescLeft">&#160;</td><td class="mdescRight">Remove an item from the recorded heap without actually freeing it.  <a href="Heap_8c.html#a5f453bffe39551109e282c904a6f2902">More...</a><br /></td></tr>
<tr class="separator:a5f453bffe39551109e282c904a6f2902"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a699e6722cc8f195f853f09ac274413a3"><td class="memItemLeft" align="right" valign="top">void *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="Heap_8c.html#a699e6722cc8f195f853f09ac274413a3">myrealloc</a> (char *file, int line, void *p, size_t size)</td></tr>
<tr class="memdesc:a699e6722cc8f195f853f09ac274413a3"><td class="mdescLeft">&#160;</td><td class="mdescRight">Reallocates a block of memory.  <a href="Heap_8c.html#a699e6722cc8f195f853f09ac274413a3">More...</a><br /></td></tr>
<tr class="separator:a699e6722cc8f195f853f09ac274413a3"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a0f10ff94faca02a6f81953c889802954"><td class="memItemLeft" align="right" valign="top">void *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="Heap_8c.html#a0f10ff94faca02a6f81953c889802954">Heap_findItem</a> (void *p)</td></tr>
<tr class="memdesc:a0f10ff94faca02a6f81953c889802954"><td class="mdescLeft">&#160;</td><td class="mdescRight">Utility to find an item in the heap.  <a href="Heap_8c.html#a0f10ff94faca02a6f81953c889802954">More...</a><br /></td></tr>
<tr class="separator:a0f10ff94faca02a6f81953c889802954"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a7fb8bd5f7469fc9c1e48c3a1f17de88a"><td class="memItemLeft" align="right" valign="top"><a id="a7fb8bd5f7469fc9c1e48c3a1f17de88a"></a>
int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="Heap_8c.html#a7fb8bd5f7469fc9c1e48c3a1f17de88a">Heap_initialize</a> (void)</td></tr>
<tr class="memdesc:a7fb8bd5f7469fc9c1e48c3a1f17de88a"><td class="mdescLeft">&#160;</td><td class="mdescRight">Heap initialization. <br /></td></tr>
<tr class="separator:a7fb8bd5f7469fc9c1e48c3a1f17de88a"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a669dfefa789daec52dd8ddc03ff1f9f9"><td class="memItemLeft" align="right" valign="top"><a id="a669dfefa789daec52dd8ddc03ff1f9f9"></a>
void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="Heap_8c.html#a669dfefa789daec52dd8ddc03ff1f9f9">Heap_terminate</a> (void)</td></tr>
<tr class="memdesc:a669dfefa789daec52dd8ddc03ff1f9f9"><td class="mdescLeft">&#160;</td><td class="mdescRight">Heap termination. <br /></td></tr>
<tr class="separator:a669dfefa789daec52dd8ddc03ff1f9f9"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a20faecf28cdd9d2fbf7d975c5b0863ef"><td class="memItemLeft" align="right" valign="top"><a class="el" href="structheap__info.html">heap_info</a> *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="Heap_8c.html#a20faecf28cdd9d2fbf7d975c5b0863ef">Heap_get_info</a> (void)</td></tr>
<tr class="memdesc:a20faecf28cdd9d2fbf7d975c5b0863ef"><td class="mdescLeft">&#160;</td><td class="mdescRight">Access to heap state.  <a href="Heap_8c.html#a20faecf28cdd9d2fbf7d975c5b0863ef">More...</a><br /></td></tr>
<tr class="separator:a20faecf28cdd9d2fbf7d975c5b0863ef"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a6cdadd76da21b7269cf5d9fc92dedb68"><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="Heap_8c.html#a6cdadd76da21b7269cf5d9fc92dedb68">HeapDumpString</a> (FILE *file, char *str)</td></tr>
<tr class="memdesc:a6cdadd76da21b7269cf5d9fc92dedb68"><td class="mdescLeft">&#160;</td><td class="mdescRight">Dump a string from the heap so that it can be displayed conveniently.  <a href="Heap_8c.html#a6cdadd76da21b7269cf5d9fc92dedb68">More...</a><br /></td></tr>
<tr class="separator:a6cdadd76da21b7269cf5d9fc92dedb68"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:aea7ea58998f69f14e16a3237c1d02d8a"><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="Heap_8c.html#aea7ea58998f69f14e16a3237c1d02d8a">HeapDump</a> (FILE *file)</td></tr>
<tr class="memdesc:aea7ea58998f69f14e16a3237c1d02d8a"><td class="mdescLeft">&#160;</td><td class="mdescRight">Dump the state of the heap.  <a href="Heap_8c.html#aea7ea58998f69f14e16a3237c1d02d8a">More...</a><br /></td></tr>
<tr class="separator:aea7ea58998f69f14e16a3237c1d02d8a"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="var-members"></a>
Variables</h2></td></tr>
<tr class="memitem:a6533888772aaa3afdee6a16a1f197087"><td class="memItemLeft" align="right" valign="top"><a id="a6533888772aaa3afdee6a16a1f197087"></a>
static pthread_mutex_t&#160;</td><td class="memItemRight" valign="bottom"><b>heap_mutex_store</b> = PTHREAD_MUTEX_INITIALIZER</td></tr>
<tr class="separator:a6533888772aaa3afdee6a16a1f197087"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:af369074ecc039810e2beb121821f09a1"><td class="memItemLeft" align="right" valign="top"><a id="af369074ecc039810e2beb121821f09a1"></a>
static mutex_type&#160;</td><td class="memItemRight" valign="bottom"><b>heap_mutex</b> = &amp;heap_mutex_store</td></tr>
<tr class="separator:af369074ecc039810e2beb121821f09a1"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a20b83c8e52be131ca41d22b8bf2c3b38"><td class="memItemLeft" align="right" valign="top"><a id="a20b83c8e52be131ca41d22b8bf2c3b38"></a>
static <a class="el" href="structheap__info.html">heap_info</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="Heap_8c.html#a20b83c8e52be131ca41d22b8bf2c3b38">state</a> = {0, 0}</td></tr>
<tr class="memdesc:a20b83c8e52be131ca41d22b8bf2c3b38"><td class="mdescLeft">&#160;</td><td class="mdescRight">global heap state information <br /></td></tr>
<tr class="separator:a20b83c8e52be131ca41d22b8bf2c3b38"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:af6c32ed140099d88362891aa068bdd09"><td class="memItemLeft" align="right" valign="top"><a id="af6c32ed140099d88362891aa068bdd09"></a>
static eyecatcherType&#160;</td><td class="memItemRight" valign="bottom"><b>eyecatcher</b> = (eyecatcherType)0x8888888888888888</td></tr>
<tr class="separator:af6c32ed140099d88362891aa068bdd09"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:aa337931db6f2e3b78d5dce6a8d228257"><td class="memItemLeft" align="right" valign="top"><a id="aa337931db6f2e3b78d5dce6a8d228257"></a>
static <a class="el" href="structTree.html">Tree</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="Heap_8c.html#aa337931db6f2e3b78d5dce6a8d228257">heap</a></td></tr>
<tr class="memdesc:aa337931db6f2e3b78d5dce6a8d228257"><td class="mdescLeft">&#160;</td><td class="mdescRight"><a class="el" href="structTree.html" title="Structure to hold all data for one tree.">Tree</a> that holds the allocation records. <br /></td></tr>
<tr class="separator:aa337931db6f2e3b78d5dce6a8d228257"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:abf84b75eac9d1e64a468ca387683d350"><td class="memItemLeft" align="right" valign="top"><a id="abf84b75eac9d1e64a468ca387683d350"></a>
static const char *&#160;</td><td class="memItemRight" valign="bottom"><b>errmsg</b> = &quot;Memory allocation error&quot;</td></tr>
<tr class="separator:abf84b75eac9d1e64a468ca387683d350"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
<div class="textblock"><p>functions to manage the heap with the goal of eliminating memory leaks </p>
<p>For any module to use these functions transparently, simply include the Heap.h header file. Malloc and free will be redefined, but will behave in exactly the same way as normal, so no recoding is necessary. </p>
</div><h2 class="groupheader">Function Documentation</h2>
<a id="a0f10ff94faca02a6f81953c889802954"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a0f10ff94faca02a6f81953c889802954">&#9670;&nbsp;</a></span>Heap_findItem()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void* Heap_findItem </td>
          <td>(</td>
          <td class="paramtype">void *&#160;</td>
          <td class="paramname"><em>p</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Utility to find an item in the heap. </p>
<p>Lets you know if the heap already contains the memory location in question. </p><dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">p</td><td>pointer to a memory location </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>pointer to the storage element if found, or NULL </dd></dl>
<div class="dynheader">
Here is the call graph for this function:</div>
<div class="dyncontent">
<div class="center"><img src="Heap_8c_a0f10ff94faca02a6f81953c889802954_cgraph.png" border="0" usemap="#aHeap_8c_a0f10ff94faca02a6f81953c889802954_cgraph" alt=""/></div>
<map name="aHeap_8c_a0f10ff94faca02a6f81953c889802954_cgraph" id="aHeap_8c_a0f10ff94faca02a6f81953c889802954_cgraph">
<area shape="rect" title="Utility to find an item in the heap." alt="" coords="5,5,112,32"/>
<area shape="rect" href="Thread_8c.html#a1c9cd0a1556e72719a5ed3f9cdf6686f" title="Lock a mutex which has alrea." alt="" coords="160,5,328,32"/>
</map>
</div>

</div>
</div>
<a id="a20faecf28cdd9d2fbf7d975c5b0863ef"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a20faecf28cdd9d2fbf7d975c5b0863ef">&#9670;&nbsp;</a></span>Heap_get_info()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="structheap__info.html">heap_info</a>* Heap_get_info </td>
          <td>(</td>
          <td class="paramtype">void&#160;</td>
          <td class="paramname"></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Access to heap state. </p>
<dl class="section return"><dt>Returns</dt><dd>pointer to the heap state structure </dd></dl>

</div>
</div>
<a id="ae75b06db0cdfce5c281f8672e8577854"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ae75b06db0cdfce5c281f8672e8577854">&#9670;&nbsp;</a></span>Heap_roundup()</h2>

<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">static size_t Heap_roundup </td>
          <td>(</td>
          <td class="paramtype">size_t&#160;</td>
          <td class="paramname"><em>size</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">static</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>Round allocation size up to a multiple of the size of an int. </p>
<p>Apart from possibly reducing fragmentation, on the old v3 gcc compilers I was hitting some weird behaviour, which might have been errors in sizeof() used on structures and related to packing. In any case, this fixes that too. </p><dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">size</td><td>the size actually needed </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>the rounded up size </dd></dl>

</div>
</div>
<a id="a5f453bffe39551109e282c904a6f2902"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a5f453bffe39551109e282c904a6f2902">&#9670;&nbsp;</a></span>Heap_unlink()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void Heap_unlink </td>
          <td>(</td>
          <td class="paramtype">char *&#160;</td>
          <td class="paramname"><em>file</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>line</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">void *&#160;</td>
          <td class="paramname"><em>p</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Remove an item from the recorded heap without actually freeing it. </p>
<p>Use sparingly! </p><dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">file</td><td>use the <b>FILE</b> macro to indicate which file this item was allocated in </td></tr>
    <tr><td class="paramname">line</td><td>use the <b>LINE</b> macro to indicate which line this item was allocated at </td></tr>
    <tr><td class="paramname">p</td><td>pointer to the item to be removed </td></tr>
  </table>
  </dd>
</dl>
<div class="dynheader">
Here is the call graph for this function:</div>
<div class="dyncontent">
<div class="center"><img src="Heap_8c_a5f453bffe39551109e282c904a6f2902_cgraph.png" border="0" usemap="#aHeap_8c_a5f453bffe39551109e282c904a6f2902_cgraph" alt=""/></div>
<map name="aHeap_8c_a5f453bffe39551109e282c904a6f2902_cgraph" id="aHeap_8c_a5f453bffe39551109e282c904a6f2902_cgraph">
<area shape="rect" title="Remove an item from the recorded heap without actually freeing it." alt="" coords="5,5,100,32"/>
<area shape="rect" href="Thread_8c.html#a1c9cd0a1556e72719a5ed3f9cdf6686f" title="Lock a mutex which has alrea." alt="" coords="148,5,316,32"/>
</map>
</div>

</div>
</div>
<a id="aea7ea58998f69f14e16a3237c1d02d8a"></a>
<h2 class="memtitle"><span class="permalink"><a href="#aea7ea58998f69f14e16a3237c1d02d8a">&#9670;&nbsp;</a></span>HeapDump()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int HeapDump </td>
          <td>(</td>
          <td class="paramtype">FILE *&#160;</td>
          <td class="paramname"><em>file</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Dump the state of the heap. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">file</td><td>file handle to dump the heap contents to </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a id="a6cdadd76da21b7269cf5d9fc92dedb68"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a6cdadd76da21b7269cf5d9fc92dedb68">&#9670;&nbsp;</a></span>HeapDumpString()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int HeapDumpString </td>
          <td>(</td>
          <td class="paramtype">FILE *&#160;</td>
          <td class="paramname"><em>file</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">char *&#160;</td>
          <td class="paramname"><em>str</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Dump a string from the heap so that it can be displayed conveniently. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">file</td><td>file handle to dump the heap contents to </td></tr>
    <tr><td class="paramname">str</td><td>the string to dump, could be NULL </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a id="aafff91620a02cc5f8160ee55dc1d7bf4"></a>
<h2 class="memtitle"><span class="permalink"><a href="#aafff91620a02cc5f8160ee55dc1d7bf4">&#9670;&nbsp;</a></span>HeapScan()</h2>

<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">static void HeapScan </td>
          <td>(</td>
          <td class="paramtype">enum LOG_LEVELS&#160;</td>
          <td class="paramname"><em>log_level</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">static</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>Scans the heap and reports any items currently allocated. </p>
<p>To be used at shutdown if any heap items have not been freed. </p>
<div class="dynheader">
Here is the call graph for this function:</div>
<div class="dyncontent">
<div class="center"><img src="Heap_8c_aafff91620a02cc5f8160ee55dc1d7bf4_cgraph.png" border="0" usemap="#aHeap_8c_aafff91620a02cc5f8160ee55dc1d7bf4_cgraph" alt=""/></div>
<map name="aHeap_8c_aafff91620a02cc5f8160ee55dc1d7bf4_cgraph" id="aHeap_8c_aafff91620a02cc5f8160ee55dc1d7bf4_cgraph">
<area shape="rect" title="Scans the heap and reports any items currently allocated." alt="" coords="5,5,88,32"/>
<area shape="rect" href="Thread_8c.html#a1c9cd0a1556e72719a5ed3f9cdf6686f" title="Lock a mutex which has alrea." alt="" coords="136,5,304,32"/>
</map>
</div>

</div>
</div>
<a id="ac23c370399a3c7b9aa9fa9d0672be122"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ac23c370399a3c7b9aa9fa9d0672be122">&#9670;&nbsp;</a></span>Internal_heap_unlink()</h2>

<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">static int Internal_heap_unlink </td>
          <td>(</td>
          <td class="paramtype">char *&#160;</td>
          <td class="paramname"><em>file</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>line</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">void *&#160;</td>
          <td class="paramname"><em>p</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">static</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>Remove an item from the recorded heap without actually freeing it. </p>
<p>Use sparingly! </p><dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">file</td><td>use the <b>FILE</b> macro to indicate which file this item was allocated in </td></tr>
    <tr><td class="paramname">line</td><td>use the <b>LINE</b> macro to indicate which line this item was allocated at </td></tr>
    <tr><td class="paramname">p</td><td>pointer to the item to be removed </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a id="a25214c297c998eba3cfc8282b1162c69"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a25214c297c998eba3cfc8282b1162c69">&#9670;&nbsp;</a></span>myfree()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void myfree </td>
          <td>(</td>
          <td class="paramtype">char *&#160;</td>
          <td class="paramname"><em>file</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>line</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">void *&#160;</td>
          <td class="paramname"><em>p</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Frees a block of memory. </p>
<p>A direct replacement for free, but checks that a item is in the allocates list first. </p><dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">file</td><td>use the <b>FILE</b> macro to indicate which file this item was allocated in </td></tr>
    <tr><td class="paramname">line</td><td>use the <b>LINE</b> macro to indicate which line this item was allocated at </td></tr>
    <tr><td class="paramname">p</td><td>pointer to the item to be freed </td></tr>
  </table>
  </dd>
</dl>
<div class="dynheader">
Here is the call graph for this function:</div>
<div class="dyncontent">
<div class="center"><img src="Heap_8c_a25214c297c998eba3cfc8282b1162c69_cgraph.png" border="0" usemap="#aHeap_8c_a25214c297c998eba3cfc8282b1162c69_cgraph" alt=""/></div>
<map name="aHeap_8c_a25214c297c998eba3cfc8282b1162c69_cgraph" id="aHeap_8c_a25214c297c998eba3cfc8282b1162c69_cgraph">
<area shape="rect" title="Frees a block of memory." alt="" coords="5,5,67,32"/>
<area shape="rect" href="Thread_8c.html#a1c9cd0a1556e72719a5ed3f9cdf6686f" title="Lock a mutex which has alrea." alt="" coords="115,5,283,32"/>
</map>
</div>

</div>
</div>
<a id="a59e53a989d69c3da767487596d9bfa1f"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a59e53a989d69c3da767487596d9bfa1f">&#9670;&nbsp;</a></span>mymalloc()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void* mymalloc </td>
          <td>(</td>
          <td class="paramtype">char *&#160;</td>
          <td class="paramname"><em>file</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>line</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">size_t&#160;</td>
          <td class="paramname"><em>size</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Allocates a block of memory. </p>
<p>A direct replacement for malloc, but keeps track of items allocated in a list, so that free can check that a item is being freed correctly and that we can check that all memory is freed at shutdown. </p><dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">file</td><td>use the <b>FILE</b> macro to indicate which file this item was allocated in </td></tr>
    <tr><td class="paramname">line</td><td>use the <b>LINE</b> macro to indicate which line this item was allocated at </td></tr>
    <tr><td class="paramname">size</td><td>the size of the item to be allocated </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>pointer to the allocated item, or NULL if there was an error </dd></dl>
<div class="dynheader">
Here is the call graph for this function:</div>
<div class="dyncontent">
<div class="center"><img src="Heap_8c_a59e53a989d69c3da767487596d9bfa1f_cgraph.png" border="0" usemap="#aHeap_8c_a59e53a989d69c3da767487596d9bfa1f_cgraph" alt=""/></div>
<map name="aHeap_8c_a59e53a989d69c3da767487596d9bfa1f_cgraph" id="aHeap_8c_a59e53a989d69c3da767487596d9bfa1f_cgraph">
<area shape="rect" title="Allocates a block of memory." alt="" coords="5,5,83,32"/>
<area shape="rect" href="Thread_8c.html#a1c9cd0a1556e72719a5ed3f9cdf6686f" title="Lock a mutex which has alrea." alt="" coords="131,5,299,32"/>
</map>
</div>

</div>
</div>
<a id="a699e6722cc8f195f853f09ac274413a3"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a699e6722cc8f195f853f09ac274413a3">&#9670;&nbsp;</a></span>myrealloc()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void* myrealloc </td>
          <td>(</td>
          <td class="paramtype">char *&#160;</td>
          <td class="paramname"><em>file</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>line</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">void *&#160;</td>
          <td class="paramname"><em>p</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">size_t&#160;</td>
          <td class="paramname"><em>size</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Reallocates a block of memory. </p>
<p>A direct replacement for realloc, but keeps track of items allocated in a list, so that free can check that a item is being freed correctly and that we can check that all memory is freed at shutdown. We have to remove the item from the tree, as the memory is in order and so it needs to be reinserted in the correct place. </p><dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">file</td><td>use the <b>FILE</b> macro to indicate which file this item was reallocated in </td></tr>
    <tr><td class="paramname">line</td><td>use the <b>LINE</b> macro to indicate which line this item was reallocated at </td></tr>
    <tr><td class="paramname">p</td><td>pointer to the item to be reallocated </td></tr>
    <tr><td class="paramname">size</td><td>the new size of the item </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>pointer to the allocated item, or NULL if there was an error </dd></dl>
<div class="dynheader">
Here is the call graph for this function:</div>
<div class="dyncontent">
<div class="center"><img src="Heap_8c_a699e6722cc8f195f853f09ac274413a3_cgraph.png" border="0" usemap="#aHeap_8c_a699e6722cc8f195f853f09ac274413a3_cgraph" alt=""/></div>
<map name="aHeap_8c_a699e6722cc8f195f853f09ac274413a3_cgraph" id="aHeap_8c_a699e6722cc8f195f853f09ac274413a3_cgraph">
<area shape="rect" title="Reallocates a block of memory." alt="" coords="5,5,83,32"/>
<area shape="rect" href="Thread_8c.html#a1c9cd0a1556e72719a5ed3f9cdf6686f" title="Lock a mutex which has alrea." alt="" coords="131,5,299,32"/>
</map>
</div>

</div>
</div>
<a id="a45db32d4f454f94d7f4574deced5ee33"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a45db32d4f454f94d7f4574deced5ee33">&#9670;&nbsp;</a></span>ptrCompare()</h2>

<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">static int ptrCompare </td>
          <td>(</td>
          <td class="paramtype">void *&#160;</td>
          <td class="paramname"><em>a</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">void *&#160;</td>
          <td class="paramname"><em>b</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>value</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">static</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p><a class="el" href="structList.html" title="Structure to hold all data for one list.">List</a> callback function for comparing storage elements. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">a</td><td>pointer to the current content in the tree (storageElement*) </td></tr>
    <tr><td class="paramname">b</td><td>pointer to the memory to free </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>boolean indicating whether a and b are equal </dd></dl>

</div>
</div>
</div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated on Fri Oct 13 2023 18:02:53 for MQTT C Client Libraries Internals by&#160;<a href="https://www.doxygen.org/index.html"><img class="footer" src="doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.9.1
</small></address>
</body>
</html>
